//+------------------------------------------------------------------+
//|                                                       Status.mqh |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
//+------------------------------------------------------------------+
//| defines                                                          |
//+------------------------------------------------------------------+
double Statistics()
  {
   double profitDay=0;
   datetime newTime=TimeCurrent();
   MqlDateTime news;
   ulong ticket=0;
   TimeToStruct(newTime,news);
   HistorySelect(0,TimeCurrent());
   for(int K = HistoryOrdersTotal()-1; K >-1 ; K--)
     {
      //printf(OrderProfit());
      if((ticket=HistoryDealGetTicket(K))>0)
        {
         datetime closeTime=HistoryDealGetInteger(ticket,DEAL_TIME);
         MqlDateTime close;
         TimeToStruct(closeTime,close);
         if(close.day==news.day)
           {
            profitDay=profitDay+HistoryDealGetDouble(ticket,DEAL_PROFIT); 
           }

        }
     }
   return profitDay;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsMove()
  {
   datetime currentTime=TimeCurrent();
   datetime vipTime=D'2034-8-30';
   bool isRun=true;
   MqlDateTime current,vip;
   TimeToStruct(currentTime,current);
   TimeToStruct(vipTime,vip);
   if(current.year>vip.year)
     {
      isRun=false;
     }
   else
      if(current.year==vip.year&&current.mon>vip.mon)
        {
         isRun=false;
        }
      else
         if(current.year==vip.year&&current.mon==vip.mon&&current.day>vip.day)
           {
            isRun=false;
           }
   return isRun;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int IsRule()
  {
   int result_states=0;
   string cookie=NULL,headers;
   char   post[],resultData[];
   string url="http://127.0.0.1/index";
   int res=WebRequest("GET",url,cookie,NULL,500,post,0,resultData,headers);
   if(res==-1)
     {
      Print("Error in WebRequest. Error code  =",GetLastError());
      //--- Perhaps the URL is not listed, display a message about the necessity to add the address
      MessageBox("Add the address '"+url+"' to the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
     }
   else
     {
      if(res==200)
        {
         //--- Successful download
         PrintFormat("The file has been successfully downloaded, File size %d byte.",ArraySize(resultData));
         //PrintFormat("Server headers: %s",headers);
         //--- Saving the data to a file
         if(resultData[0]==48)
           {
            result_states=0;
           }
         else
            if(resultData[0]==49)
              {
               result_states=1;
              }
            else
               if(resultData[0]==50)
                 {
                  result_states=2;
                 }
        }
      else
        {
         PrintFormat("Downloading '%s' failed, error code %d",url,res);
        }
     }
   return result_states;
  }  
//+------------------------------------------------------------------+
